package com.learn._01mvcboot01.controller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
public class BMIController {

    /*
    * GET测试：http://localhost:8080/bmi?height=1.75&weight=70
    * POST测试：http://localhost:8080/bmi
    * */
    @RequestMapping("/bmi")
    @ResponseBody
    public String calcBMI(double height,double weight){
        System.out.println("height="+height+",weight="+weight);
        double bmi = weight/(height*height);
        System.out.println("bmi="+bmi);
        if(bmi<18.5){
            return "偏瘦";
        } else if (bmi < 24) {
            return "正常";
        } else if (bmi < 27) {
            return "微胖";
        }else {
            return "该减肥了";
        }
    }
}
